package com.theme.passport.service.theme.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.theme.common.mvc.utils.PageUtils;
import com.theme.common.mvc.utils.Query;


import com.theme.passport.dao.theme.WidgeWeatherImagesDao;
import com.theme.passport.entity.theme.WidgeConfigEntity;
import com.theme.passport.entity.theme.WidgeWeatherImagesEntity;
import com.theme.passport.service.theme.WidgeWeatherImagesService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

@Service("WidgeWeatherImagesService")
public class WidgeWeatherImagesServiceImpl extends ServiceImpl<WidgeWeatherImagesDao, WidgeWeatherImagesEntity> implements WidgeWeatherImagesService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<WidgeWeatherImagesEntity> page = this.page(
                new Query<WidgeWeatherImagesEntity>().getPage(params),
                new QueryWrapper<WidgeWeatherImagesEntity>()
        );

        return new PageUtils(page);
    }


    @Override
    public List<Long> queryWidgeConfigAll(String widge_id) {
        return baseMapper.queryWidgeConfigAll(widge_id);
    }

    @Override
    public List<String> queryWidgeWeatherImagesByConfigId(String widge_config_id) {
//       List<WidgeWeatherImagesEntity> weatherImages = this.baseMapper.queryWidgeWeatherImagesByConfigId(widge_config_id);
        Wrapper<WidgeWeatherImagesEntity> queryWrapper = new QueryWrapper<WidgeWeatherImagesEntity>()
                .eq("widge_config_id", widge_config_id);
        List<WidgeWeatherImagesEntity> weatherImages = this.baseMapper.selectList(queryWrapper);
       List<String> urlList = new ArrayList<>();
       for (WidgeWeatherImagesEntity weatherImage : weatherImages){
           urlList.add(weatherImage.getFileUrl());
       }
        return urlList;
    }

}
